
<?php
include_once("adb.php");

class service extends adb
{
    function service()
    {
        adb::adb();
    }
    /**
     *query all vaccines in the table and store the dataset in $this->result
     *@return if successful true else false
     */

    function get_all_services()
    {
        $query="select service_id,service_offered,household_id,community_member_id,date_offered from Services";
        return $this->query($query);
    }

    function add_service($service_offered,$household_id,$community_member_id,$date_offered)
    {
        //write the SQL query and call $this->query()
        $query = "insert into Services set service_offered='$service_offered',
			household_id='$household_id',community_member_id='$community_member_id',
			date_offered='$date_offered'";
        return $this->query($query);
    }

    /**
     *updates the record identified by id
     */
    function update_service($service_id,$service_offered,$household_id,$community_member_id,$date_offered){
        $query = "update Services set
	        service_offered='$service_offered',
			household_id='$household_id',
			community_member_id='$community_member_id',
			date_offered='$date_offered'
			 where service_id='$service_id'";
        if(!$this -> query($query))
        {
            return false;
        }
        return true;
    }

    function search_services($serviceid)
    {
        $query = "select * from Services where service_id like '%$serviceid%' or 
        service_offered like '%$serviceid%' or household_id like '%$serviceid%' or
        community_member_id like '%$serviceid%' or date_offered like '%$serviceid%'" ;
       
        return $this -> query($query);

    }

    function delete_services($service_id){
        $query = "delete from Services where service_id='$service_id'";

        return $this -> query($query);
    }

    function get_service($id)
    {
        $query = "select service_id,service_offered,household_id,community_member_id,date_offered from Services where service_id = $id";
        if(!$this -> query($query))
        {
            return false;
        }
        return $this -> fetch();
    }
}

?>
